%
% Copyright (C) 2019-2023 by Jingxuan Yang <yanglatex2e@gmail.com>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%      http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL1.3c maintenance status `maintained'.
%
\ProvidesPackage{hitszthesis}[2023/11/27 v3.3 Style Collection of Dissertation Template for Harbin Institute of Technology, ShenZhen (HITSZ)]

% 此文件声明不在规范中要求的格式所使用的宏包

% 根据窝工规范中对数字书写规范的规定（6）：
% 凡4位或4位以上的数都从个位起每3位数空半个数码(1/4汉字)。
% 注意此处，除此任何空格都是错误的（包括\:\;\ 等）
\RequirePackage{siunitx}
\sisetup{group-minimum-digits=4, group-separator= \hspace{0.25em}}
\sisetup{detect-weight,detect-mode,detect-family}

% 处理数学公式中的黑斜体的宏包
\RequirePackage{bm}

% 不同于 \mathcal \mathfrak 之类的英文花体字体
\RequirePackage{mathrsfs}

% 支持彩色
\RequirePackage{xcolor}
\definecolor{colorzero}{rgb}{0, 0, 0}
\definecolor{colorone}{rgb}{1, 0, 0}
\definecolor{colortwo}{rgb}{0, 0, 1}
\definecolor{colorthree}{rgb}{0, 1, 0}

% 图形和表格的控制旋转
\RequirePackage{rotating}

% 输出无意义文字
\RequirePackage{lipsum}

% 算法的宏包，注意宏包兼容性，先后顺序为 float、hyperref、algorithm(2e)，否则无法
% 生成算法列表。我工算法混乱问题详见hithesis文档。各个实验室设置具体方法详见
% hithesis文档或者示例中给出的地址。
\RequirePackage[algoruled,linesnumbered,algochapter]{algorithm2e}
\SetAlCapSty{}
\newcommand{\foocaption}[1]{ \def\@algocf@pre@plainruled{\hrule height1.5pt depth0pt\kern\interspacetitleruled #1 \kern\interspacealgoruled\hrule height1pt depth0pt\kern\interspacetitleruled} }
\def\@algocf@post@ruled{\kern\interspacealgoruled\hrule height1.5pt\relax}%

% 算法英文标题
\newcommand{\algoenname}{Algo.}
\newfloatlist[chapter]{algoen}{aen}{\listalgoenname}{\algoenname}
\newfixedcaption{\algoencaption}{algoen}
\renewcommand{\thealgoen}{\thechapter-\arabic{algocf}}
\renewcommand{\@cftmakeaentitle}{\chapter*{\listalgoenname\@mkboth{\listalgoenname}{\listalgoenname}}
}
\renewcommand{\algorithmcfname}{算法}
\setlength\AlCapSkip{1.2ex}
\SetAlgoSkip{1pt}
\renewcommand{\algocf@captiontext}[2]{\wuhao#1\algocf@typo~\AlCapFnt{}#2} % text of caption
\expandafter\ifx\csname algocf@within\endcsname\relax% if \algocf@within doesn't exist
\renewcommand\thealgocf{\@arabic\c@algocf} % and the way it is printed
\else%                                    else
\renewcommand\thealgocf{\csname the\algocf@within\endcsname-\@arabic\c@algocf}
\fi
\renewcommand{\algocf@makecaption}[2]{%中英文双标题一定多于一行，因此去掉单行时的判断，并将\parbox中标题设置为居中
  \addtolength{\hsize}{\algomargin}%
  \sbox\@tempboxa{\algocf@captiontext{#1}{#2}}%
    \hskip .5\algomargin%
    \parbox[t]{\hsize}{\centering\algocf@captiontext{#1}{#2}}%
  \addtolength{\hsize}{-\algomargin}%
}
\newcommand{\AlgoBiCaption}[2]{%直接取出自定义的中英文标题条目加入到真正的\caption 中
   \caption[#1]{\protect\setlength{\baselineskip}{1.5em}#1 \protect \\ Algo.\thealgocf~#2} % \algoencaption{#2}
   \addcontentsline{aen}{algoen}{\protect\numberline{\thealgoen}{#2}}
}

% 排版源码所使用的环境可以有两种。listings和minted
\RequirePackage{listings}

% 定义代码颜色
\definecolor{lightgrey}{rgb}{0.9,0.9,0.9}
\definecolor{frenchplum}{RGB}{190,20,83}
\definecolor{winered}{rgb}{0.5,0,0}

% 设置 \LaTeX 代码排版样式
\lstset{language = [LaTeX]TeX,
  basicstyle = \small\ttfamily,
  texcsstyle = *\color{winered},
  numbers = left,
  stepnumber=1,
  numberstyle=\small\ttfamily,
  numbersep=10pt,
  mathescape,
  breaklines = true,
  keywordstyle = \color{winered},
  commentstyle = \color{gray},
  emph = {fontenc,fontspec,xeCJK,FiraMono,xunicode,newtxmath,
  figure,fig,image,img,table,itemize,enumerate,newtxtext,newtxtt,
  ctex, microtype,description,times,newtx,booktabs,tabular,
  PDFLaTeX,XeLaTeX,type1cm,BibTeX,device,color,mode,lang,
  amsthm,tcolorbox,titlestyle,cite,marginnote,ctex,listings,base,
  subnumcases,subeqnarray},
  emphstyle = {\color{frenchplum}},
  morekeywords = {DeclareSymbolFont,SetSymbolFont,toprule,midrule,bottomrule,
  institute,version,includegraphics,setmainfont,setsansfont,
  setmonofont,setCJKmainfont,setCJKsansfont,setCJKmonofont,
  RequirePackage,figref, tabref,email,maketitle,keywords,definecolor,
  extrainfo,logo,cover,subtitle,appendix,chapter,hypersetup,
  mainmatter,frontmatter,tableofcontents, hitszpar,heiti,kaishu,lstset,
  pagecolor,zhnumber,marginpar,part, equote,marginnote,slabel},
  frame = single,
  tabsize = 2,
  rulecolor = \color{black},
  framerule = 0.2pt,
  columns = flexible,
  % backgroundcolor = \color{lightgrey}
}

% 或者使用minted 包。如果使用该包，需要在编译时加-shell-escape选项，且需要安装
% pygmentatize 工具对代码进行高亮。
% \RequirePackage{minted}
%

% 术语宏包，用来处理首次全写，之后缩写的问题
\RequirePackage{glossaries}
\setacronymstyle{short-long}
\renewcommand*{\genacrfullformat}[2]{%
   \glsentrylong{#1}%
}
% \makeglossaries

% 添加术语举例
\newacronym{tssbp}{树结构折筷过程}{树结构折筷过程（Tree-structured Stick-breaking process）}
\def\gtssbp{\gls{tssbp}\sindex[china]{shu!树结构折筷过程}\sindex[english]{Tree-structured Stick-breaking process}}

\newacronym[shortplural=SCNAs,longplural={体细胞拷贝数变异（Somatic copy number alternation，SCNA）}]{scna}{SCNA}{体细胞拷贝数变异（Somatic copy number alternation，SCNA）}
\def\gscna{\gls{scna}\sindex[china]{ti!体细胞拷贝数变异}\sindex[english]{Somatic copy number alternation}\ignorespaces}
\def\gscnas{\glspl{scna}\sindex[china]{ti!体细胞拷贝数变异}\sindex[english]{Somatic copy number alternation}\ignorespaces}

% tikz做图宏宏包
\usepackage{tikz}
% 此处可以定义一些tikz全局样式
% \tikzstyle{nodestyle}= [circle, fill=gray!60]
% \tikzstyle{edgestyle}= [-latex]

% 最后定义一些常见的数学公式样式
\newcommand{\theVector}[1]{\bm{#1}}
\newcommand{\theMatrix}[1]{\mathbb{#1}}
\newcommand{\theSet}[1]{\mathcal{#1}}
\newcommand{\theDirected}[1]{{\overrightarrow{#1}}}
\newcommand{\theUndirected}[1]{{\overline{#1}}}
\newcommand{\theNetwork}[1]{\mathscr{#1}}
\newcommand{\theNode}[1]{{\text{#1}}}
\newcommand{\theDirectedEdge}[2]{{\overrightarrow{{#1}{#2}}}}
\newcommand{\theUndirectedEdge}[2]{{\overline{{#1}{#2}}}}

% 新简记数学命令
\newcommand\dif{\text{d}}
\newcommand\no{\noindent}
\newcommand\dis{\displaystyle}
\newcommand\ls{\leqslant}
\newcommand\gs{\geqslant}

% 极限
\newcommand\limit{\dis\lim\limits}
\newcommand\limn{\dis\lim\limits_{n\to\infty}}
\newcommand\limxz{\dis\lim\limits_{x\to0}}
\newcommand\limxi{\dis\lim\limits_{x\to\infty}}
\newcommand\limxpi{\dis\lim\limits_{x\to+\infty}}
\newcommand\limxni{\dis\lim\limits_{x\to-\infty}}
\newcommand\limtpi{\dis\lim\limits_{t\to+\infty}}
\newcommand\limtni{\dis\lim\limits_{t\to-\infty}}

% n求和
\newcommand\sumn{\dis\sum\limits_{n=1}^{\infty}}
\newcommand\sumnz{\dis\sum\limits_{n=0}^{\infty}}

% i求和
\newcommand\sumi{\dis\sum\limits_{i=1}^{\infty}}
\newcommand\sumiz{\dis\sum\limits_{i=0}^{\infty}}
\newcommand\sumin{\dis\sum\limits_{i=1}^{n}}
\newcommand\sumizn{\dis\sum\limits_{i=0}^{n}}

% k求和
\newcommand\sumk{\dis\sum\limits_{k=1}^{\infty}}
\newcommand\sumkz{\dis\sum\limits_{k=0}^{\infty}}
\newcommand\sumkn{\dis\sum\limits_{k=0}^n}
\newcommand\sumkfn{\dis\sum\limits_{k=1}^n}

% z偏微分
\newcommand\pzx{\dis\frac{\partial z}{\partial x}}
\newcommand\pzy{\dis\frac{\partial z}{\partial y}}

% f偏微分
\newcommand\pfx{\dis\frac{\partial f}{\partial x}}
\newcommand\pfy{\dis\frac{\partial f}{\partial y}}

% z二重偏微分
\newcommand\pzxx{\dis\frac{\partial^2 z}{\partial x^2}}
\newcommand\pzxy{\dis\frac{\partial^2 z}{\partial x\partial y}}
\newcommand\pzyx{\dis\frac{\partial^2 z}{\partial y\partial x}}
\newcommand\pzyy{\dis\frac{\partial^2 z}{\partial y^2}}

% f二重偏微分
\newcommand\pfxx{\dis\frac{\partial^2 f}{\partial x^2}}
\newcommand\pfxy{\dis\frac{\partial^2 f}{\partial x\partial y}}
\newcommand\pfyx{\dis\frac{\partial^2 f}{\partial y\partial x}}
\newcommand\pfyy{\dis\frac{\partial^2 f}{\partial y^2}}

% 积分
\newcommand\intzi{\dis\int_{0}^{+\infty}}
\newcommand\intd{\dis\int}
\newcommand\intab{\dis\int_a^b}

% 角度符号
\newcommand{\degree}{^\circ}

% 花体
\newcommand\ma{\mathcal{A}}
\newcommand\mb{\mathcal{B}}
\newcommand\mc{\mathcal{C}}
\newcommand\me{\mathcal{E}}
\newcommand\mg{\mathcal{g}}

% 重体
\newcommand\mcc{\mathbb{C}}
\newcommand\mrr{\mathbb{R}}
\newcommand\mzz{\mathbb{Z}}

% 向量
\newcommand\vx{\mathbf{x}}
\newcommand\vX{\mathbf{X}}
\newcommand\vy{\mathbf{y}}
\newcommand\vY{\mathbf{Y}}

% 定义新数学符号
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\arccot}{arccot}
\DeclareMathOperator{\arccosh}{arccosh}
\DeclareMathOperator{\arcsinh}{arcsinh}
\DeclareMathOperator{\arctanh}{arctanh}
\DeclareMathOperator{\arccoth}{arccoth}
\DeclareMathOperator{\grad}{\bf{grad}}
\DeclareMathOperator{\argmax}{argmax}
\DeclareMathOperator{\argmin}{argmin}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\csign}{csign}

% 定义命令
\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
\def\cmd@to@cs#1#2{\char\number`#2\relax}
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\endinput
